<template>
  <div>
    <!-- 头部部分 -->
    <header class="header">
      <h1>todos</h1>
      <input
        @keydown.enter="add"
        v-model.trim="val"
        class="new-todo"
        placeholder="请输入任务名称"
        autofocus
      />
    </header>
  </div>
</template>

<script>
export default {
  name: "VuecliDayyiTodoHeader",

  data() {
    return {
      valname: "",
    };
  },
  methods: {
    add() {
      // 非空判断
      if (this.valname === "") return;
      this.$emit("addVal", this.valname);
      this.val = "";
    },
  },
};
</script>

<style lang="scss" scoped>
</style>